package com.bjpowernode.edu.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bjpowernode.edu.domain.CourseVo;
import com.bjpowernode.edu.domain.TPosition;
import com.bjpowernode.edu.exception.MyException;
import com.bjpowernode.edu.service.TPositionService;
import com.bjpowernode.edu.mapper.TPositionMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class TPositionServiceImpl extends ServiceImpl<TPositionMapper, TPosition>
    implements TPositionService{
    @Autowired
    private TPositionMapper tPositionMapper;

    @Override
    public List<TPosition> listAll(CourseVo courseVo) {
        //PageHelper.startPage(courseVo.getCurrentPage(), courseVo.getPageSize());
        List<TPosition> list = tPositionMapper.listAll(courseVo);
        return  list;
    }

    @Override
    public void delete(Integer pid) {
        if (pid != null) {
            int result = tPositionMapper.deleteById(pid);
            if (result != 1){
                throw new MyException("删除失败");
            }
        }else {
            throw new MyException("删除失败");
        }
    }

    @Override
    public void insert(TPosition tPosition) {
        if (tPosition.getPid() == null) {
            int list = tPositionMapper.insert(tPosition);
            if (list != 1) {
                throw new MyException("新建失败");
            }
        }
    }




}




